/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.storage.api;

import com.jeesite.modules.storage.service.ActivityService;
import com.jeesite.modules.storage.common.ServerResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * 营销活动Controller
 */
@RestController(value = "apiactivity")
@RequestMapping(value = "/api/activity")
public class ActivityController extends APIController {

    @Autowired
    private ActivityService activityService;

    /**
     * 搜索活动列表
     * @param memberId 会员Id
     * @param keywords 关键字
     * @param size 每页数量
     * @param page 页码
     * @return 活动列表
     */
    @RequestMapping(method = RequestMethod.GET,value = "search")
    @ResponseBody
    public ServerResponse<List<Map>> search(@RequestParam(value = "memberId")String memberId,@RequestParam(value = "keywords")String keywords, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,activityService.getSearchMaps(memberId,keywords,size,page));
    }

    /**
     * 今日上新
     * @param memberId 会员Id
     * @param size 每页数量
     * @param page 页码
     * @return 活动列表
     */
    @RequestMapping(method = RequestMethod.GET,value = "hot")
    @ResponseBody
    public ServerResponse<List<Map>> hot(@RequestParam(value = "memberId")String memberId, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,activityService.getHotMaps(memberId,size,page));
    }

    /**
     * 爆款时间
     * @return 爆款时间
     */
    @RequestMapping(method = RequestMethod.GET,value = "limitedtimes")
    @ResponseBody
    public ServerResponse<List<String>> limitedTimes(){
        return ServerResponse.createBySuccess(200,activityService.getLimitedTimes());
    }

    /**
     * 即将开售
     * @param memberId 会员Id
     * @param size 每页数量
     * @param page 页码
     * @return 活动列表
     */
    @RequestMapping(method = RequestMethod.GET,value = "sale")
    @ResponseBody
    public ServerResponse<List<Map>> sale(@RequestParam(value = "memberId")String memberId, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,activityService.getSaleMaps(memberId,size,page));
    }

    /**
     * 统计汇总【阶段】
     * @return 统计汇总【阶段】
     */
    @RequestMapping(method = RequestMethod.GET,value = "stages")
    @ResponseBody
    public ServerResponse<Map> stages(){
        return ServerResponse.createBySuccess(200,activityService.getStages());
    }

    /**
     * 查询活动列表
     * @param type 类型【Hot热播 Sale预告】
     * @param identity 标识【Today今日 Yesterday昨日 Earlier更早 Tomorrow明日 AfterTomorrow后日】
     * @param cateId 分类Id
     * @param size 每页数量
     * @param page 页码
     * @return 活动列表
     */
    @RequestMapping(method = RequestMethod.GET,value = "query")
    @ResponseBody
    public ServerResponse<List<Map>> query(@RequestParam(value = "type")String type,@RequestParam(value = "identity")String identity,@RequestParam(value = "cateId")String cateId, @RequestParam(value="size",defaultValue = "10") Integer size, @RequestParam(value="page",defaultValue = "1") Integer page){
        return ServerResponse.createBySuccess(200,activityService.getList(type,identity,cateId,size,page));
    }
}
